import topNav from '../plug-page/topnav.vue'
import footerNav from '../plug-page/footernav.vue'

export default {
    name: 'about',
    data () {
        return {
            bussiness: 'bussiness!',
        }
    },
    mounted() {
        window.scrollTo(0,0);
        this.setTitle();
        this.slideScroll();
        this.toTop();
    },
    components: {
        topNav,
        footerNav,
    },
    methods: {
        setTitle(){
            document.title = '智媒云图 - 业务体系';
        },
        loading(){

        },
        slideScroll(){
            var navTop = $('#descSlide').offset().top,
                $descSlideNav = $('.descSlide-nav'),
                $title1 = $('#title1').offset().top,
                $title2 = $('#title2').offset().top,
                $title3 = $('#title3').offset().top,
                $title4 = $('#title4').offset().top;
            $(window).scroll(function(){
                var scrTop = $(window).scrollTop();
                if(scrTop+navTop>=$title4){
                    $descSlideNav.find('a').removeClass('active').eq(3).addClass('active');
                }else if(scrTop+navTop>=$title3){
                    $descSlideNav.find('a').removeClass('active').eq(2).addClass('active');
                }else if(scrTop+navTop>=$title2){
                    $descSlideNav.find('a').removeClass('active').eq(1).addClass('active');
                }else{
                    $descSlideNav.find('a').removeClass('active').eq(0).addClass('active');
                }
            });
        },
        toTop: function(){
            $('#toTop').on('click', function(){
                $('html, body').animate({scrollTop: 0},400);
            });
        },
        slideScroll : function (title,e) {
            if($('#'+title).length < 1) return;
            $('html,body').animate({
                scrollTop : $('#'+title).offset().top-$('.nav').height()
            })
            $('.descSlide-nav a').removeClass();
            $(e.target).addClass('active');
        }
    }
}

